<%@page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<!-- public quote -->
<%@include file="/jsp/comm_css_include.jsp"%>
<!-- jqgrid-->
<link
	href="${basePath}/css/plugins/jqgriddemo/css/ui.jqgrid-bootstrap.min.css"
	rel="stylesheet" />
<!doctype html>
<html>
<head>
<style type="text/css">
* {
	margin: 0px;
	padding: 0px;
	font-size: 12px;
}

.laydate-icon {
	height: 20px;
}
</style>
</head>
<body class="gray-bg">
	<div class="wrapper wrapper-content animated fadeInRight">
		<div class="iboxtitle">
			<span>业务受理&nbsp;&gt;&nbsp;基本资料登记</span>
		</div>
		<div class="ibox-content">
			<div role="form" class="form-inline">
				<div class="form-group">
					<label class="sr-only">客户名：</label> <input type="text"
						placeholder="客户名" id="customerName" name="customerName"
						class="form-control">
				</div>
				<div class="form-group">
					<label class="sr-only">业务员：</label> <input type="text"
						placeholder="业务员" id="salesmanName" name="salesmanName"
						class="form-control">
				</div>
				<button class="zhixcx" type="button" onclick="query();">执行查询</button>
			</div>
		</div>
		<div class="ibox-content">
			<div class="jqGrid_wrapper">
				<table id="table_list_1"></table>
				<div id="pager_list_1"></div>
			</div>
		</div>
	</div>


	<!-- public quote -->
	<%@include file="/jsp/comm_js_include.jsp"%>

	<!-- jqGrid -->
	<script type="text/javascript" charset="utf-8"
		src="${basePath}/js/plugins/jqgriddemo/js/jquery.jqGrid.min.js"></script>
	<script type="text/javascript" charset="utf-8"
		src="${basePath}/js/plugins/jqgriddemo/js/grid.locale-cn.min.js"></script>

	<!-- layerDate plugin javascript -->
	<script src="${basePath}/js/plugins/layer/laydate/laydate.js"></script>


	<!--
    	作者：zhangpp
    	时间：2017-04-06
    	描述：js
    -->
	<script type="text/javascript">
	    
	    var winWidth = $(window).width();
		var winHeight = $(window).height();
		
	    jQuery(function($) {  
	    	getData();
	    });
	    
	    var getData = function(){
   	   	   winWidth = $(window).width();
   	   	   winHeight = $(window).height() / 2.5;
  		   var win = winWidth / 7 - 20;
  		
  	 	   $.jgrid.defaults.styleUI = 'Bootstrap';
		  jQuery("#table_list_1").jqGrid
		  ({
			url:'${basePath}/YwBusinessController/tongrongList',
	        datatype : "json",
	        colNames : [ '主键','业务提交时间', '经销商', '部门','业务员', '客户姓名', '身份证号码', '银行','操作'],
	        colModel : [ 
	                     {name: 'replaceId', index: 'B.id', hidden:true},
	                     {name: 'submitTime',index: 'B.submitTime',width: win,align: "center"},
	               		 {name: 'dealerName',index: 'BDI.dealerName',width: win,align: "center"},
	            		 {name: 'orgName',index: 'BO.orgName',width: win,align: "center"},
	            		 {name: 'salesmanName',index: 'C.salesmanName',width: win,align: "center"},
	            		 {name: 'customerName',index: 'B.customerName',width: win,align: "center"},
	            		 {name: 'customerNo',index: 'B.customerNo',width: win,align: "center"},
	            		 {name: 'bankLoanDisplay',index: 'B.bankLoan',width: win,align: "center"},
	            		 {name: 'oper',index: 'oper',width: win,align: "center",sorttype: "float",
	            			 formatter: function (cellvalue, options, rowObject) {
	            				 var but = '<button type="button" class="btn btn-outline btn-primary" onclick="tongrong();">申请通融</button>';
	            				 return but;
	            			 }
	               		 }
	                   ],
              mtype : "post",
              height: winHeight,
              width:winWidth,  
              autowidth: false,
              shrinkToFit: false,
              rowNum: 15,
              rowList: [15, 30, 45],
              viewrecords: true,
              pager: "#pager_list_1",
              hidegrid: false,
              multiselect : false,
              altRows:true,
              altclass:'someClass',
              jsonReader : {
            	  root:"result.rows",
            	  page: "result.page",
            	  total: "result.total",
            	  records: "result.records",
            	  repeatitems: false,
            	  id: "replaceId"
              },
              loadComplete:function(datas){
            	  if (datas.flag == "100100") {
                      layer.msg("查询成功!", {icon: 6, time: 1000});
                      return;
                  }
            	  if(datas.flag == '100802') {
    				  top.location.href = thisLoginUrl;
    				  return;
    			  }

            	  layer.msg(datas.message, {icon: 2});
              }
	      });
	    }	    
	    var tongrong=function(){
	    	var data={};
	    	var id=$("#table_list_1").jqGrid("getGridParam","selrow");
	    	var rowData = $("#table_list_1").jqGrid("getRowData",id);
	    	data.busiId=rowData[0].replaceId;
	    	$.dpAjax({
	    		url:'${basePath}/YwTongrongController/tongrong',
	    		data:data,
    			success: function(datas){
	    			  if(datas.flag == "100100")
					  {
						  layer.msg('执行成功！', {icon: 6});
					  }
					  if(datas.flag == "100200")
	                  {
						  $.fn.showDatas({"datas":datas});
	                	  return;
	                  }
                 }
	    	});
	    }
	    window.onresize = function()
	    {
	    	$("#table_list_1").setGridWidth($(window).width()-80);
	    }
	    
	    var query = function()
	    {
	    	var postData = $("#table_list_1").jqGrid("getGridParam", "postData");
	    	var data = {};
	    	data.customerName = document.getElementById('customerName').value || '';
	    	data.salesmanName = document.getElementById('salesmanName').value || '';
	    	$.extend(postData, data);
	    	refresh();
	    }
	    
	    var refresh = function()
	    {
	    	$("#table_list_1").jqGrid("setGridParam", { search: true }).trigger("reloadGrid", [{ page: 1}]);
	    }
    </script>
</body>
</html>
